#!/bin/sh /etc/rc.common
# Copyright (C) 2016 www.phicomm.com

START=99
. /usr/lib/device_manage_set.sh

cfg_reload() {
	local section_name=$1
	local MAC
	local if_type
	local block_user

	config_get MAC "$section_name" mac
	config_get block_user "$section_name" block_user
	if [ $block_user -ne 0 ]; then
		config_get if_type "$section_name" if_type
		if [ "$if_type" = "0" ]; then
			block_user_set $if_type $block_user "0"
		fi
	fi
}

start() {
	iptables -t mangle -w -F limit_chain >/dev/null 2>&1
	iptables -t mangle -w -D FORWARD -j limit_chain > /dev/null 2>&1
	iptables -t mangle -w -X limit_chain >/dev/null 2>&1
	iptables -t mangle -w -N limit_chain >/dev/null 2>&1
	iptables -t mangle -w -I FORWARD -j limit_chain > /dev/null 2>&1
	config_load wireless
	config_foreach policy_init wifi-iface
	config_load device_manage
	config_foreach cfg_reload limit
}

